import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorklineVO, WorklineForm, WorklineQuery } from '@/api/base/factory/workline/types';

/**
 * 查询产线管理列表
 * @param query
 * @returns {*}
 */
export const listWorkline = (query?: WorklineQuery): AxiosPromise<WorklineVO[]> => {
  return request({
    url: '/base/factory/workline/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取产线管理列表
 * @param query
 * @returns {*}
 */
export const queryList = (query?: WorklineForm): AxiosPromise<WorklineForm[]> => {
  return request({
    url: '/base/factory/workline/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询产线管理详细
 * @param id
 */
export const getWorkline = (id: string | number): AxiosPromise<WorklineVO> => {
  return request({
    url: '/base/factory/workline/' + id,
    method: 'get'
  });
};

/**
 * 新增产线管理
 * @param data
 */
export const addWorkline = (data: WorklineForm) => {
  return request({
    url: '/base/factory/workline',
    method: 'post',
    data: data
  });
};

/**
 * 修改产线管理
 * @param data
 */
export const updateWorkline = (data: WorklineForm) => {
  return request({
    url: '/base/factory/workline',
    method: 'put',
    data: data
  });
};

/**
 * 删除产线管理
 * @param id
 */
export const delWorkline = (id: string | number | Array<string | number>) => {
  return request({
    url: '/base/factory/workline/' + id,
    method: 'delete'
  });
};

export default {
  queryList
};
